﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;

namespace HZ.DrugTrade.Web
{
    public partial class getstatus1 : System.Web.UI.Page
    {
        IBLL_Company IBC = Factory.BLL_Company();

        IBLL_SelectRelation iselectRelation = Factory.BLL_SelectRelation();

        protected void Page_Load(object sender, EventArgs e)
        {
            setReadme();
        }

        protected void test_Click(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        protected void setReadme()
        {

            int iccount = IBC.GetAllCompanyCount();
            int iscount= iselectRelation.GetSelectRelationCount();

            this.lblReadme.Text = string.Format(@"配送企业数量：{0}；<br/>
            已建立配送关系数量：{1}；<br/>",iccount.ToString(), iscount.ToString());
        }

        protected void btnCheck_Click(object sender, EventArgs e)
        {
            DataTable dt = iselectRelation.GetEspeciallyRelationShip();
            if (dt.Rows.Count > 0)
            {
                this.btnUpdate.Visible = true;
                lblCount.Text = " 共计 " + dt.Rows.Count.ToString() + " 条 ";
            }
            else
            {
                this.btnUpdate.Visible = false;
                lblCount.Text = "";
            }
            this.grvCheckList.DataSource = dt;
            this.grvCheckList.DataBind();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (iselectRelation.UpdateEspeciallyRelationShip() == 1)
            {
                HZ.Web.WebUtil.Alert("操作成功！");

                btnCheck_Click(sender, e);
            }
            else
            {
                HZ.Web.WebUtil.Alert("操作失败！");
            }
        }
    }
}
